---
root: "/v5.1"
layout: "default"
title: "OpaquePointer"
description: "Swift documentation for 'OpaquePointer'"
keywords: ""
---

<div class="intro-declaration"><code class="language-swift">struct OpaquePointer</code></div><p>A wrapper around an opaque C pointer.</p>
<table class="standard"><tr><th id="inheritance">Inheritance</th><td><code class="inherits">CustomDebugStringConvertible, Equatable, Hashable</code></td></tr></table><div class="discussion comment"><p>Opaque pointers are used to represent C pointers to types that
cannot be represented in Swift, such as incomplete struct types.</p>
</div><h3>Initializers</h3><div id="init-00a2b987552997ee43208aca83ac6ae6" class="declaration"><a class="toggle-link" href="#comment-init-00a2b987552997ee43208aca83ac6ae6">init init(_:)</a> <span class="required">Required</span><div class="comment collapse in" id="comment-init-00a2b987552997ee43208aca83ac6ae6"><p>Converts a typed <code>UnsafePointer</code> to an opaque C pointer.</p>
<h4>Declaration</h4><code class="language-swift">public init&lt;T>(_ from: UnsafePointer&lt;T>)</code></div></div><div id="init-00a2b987552997ee43208aca83ac6ae6" class="declaration"><a class="toggle-link" href="#comment-init-00a2b987552997ee43208aca83ac6ae6">init init(_:)</a> <span class="required">Required</span><div class="comment collapse in" id="comment-init-00a2b987552997ee43208aca83ac6ae6"><p>Converts a typed <code>UnsafeMutablePointer</code> to an opaque C pointer.</p>
<h4>Declaration</h4><code class="language-swift">public init&lt;T>(_ from: UnsafeMutablePointer&lt;T>)</code></div></div><div id="init-00a2b987552997ee43208aca83ac6ae6" class="declaration"><a class="toggle-link" href="#comment-init-00a2b987552997ee43208aca83ac6ae6">init init(_:)</a> <span class="required">Required</span><div class="comment collapse in" id="comment-init-00a2b987552997ee43208aca83ac6ae6"><h4>Declaration</h4><code class="language-swift">public init(_ from: UnsafeMutableRawPointer)</code></div></div><div id="init-00a2b987552997ee43208aca83ac6ae6" class="declaration"><a class="toggle-link" href="#comment-init-00a2b987552997ee43208aca83ac6ae6">init init(_:)</a> <span class="required">Required</span><div class="comment collapse in" id="comment-init-00a2b987552997ee43208aca83ac6ae6"><h4>Declaration</h4><code class="language-swift">public init(_ from: UnsafeRawPointer)</code></div></div><div id="init-48690522e4b66d2b1596ce439b7dd9cd" class="declaration"><a class="toggle-link" href="#comment-init-48690522e4b66d2b1596ce439b7dd9cd">init init?(_:)</a> <span class="required">Required</span><div class="comment collapse in" id="comment-init-48690522e4b66d2b1596ce439b7dd9cd"><p>Converts a typed <code>UnsafePointer</code> to an opaque C pointer.</p>
<p>The result is <code>nil</code> if <code>from</code> is <code>nil</code>.</p>
<h4>Declaration</h4><code class="language-swift">public init?&lt;T>(_ from: UnsafePointer&lt;T>?)</code></div></div><div id="init-48690522e4b66d2b1596ce439b7dd9cd" class="declaration"><a class="toggle-link" href="#comment-init-48690522e4b66d2b1596ce439b7dd9cd">init init?(_:)</a> <span class="required">Required</span><div class="comment collapse in" id="comment-init-48690522e4b66d2b1596ce439b7dd9cd"><p>Converts a typed <code>UnsafeMutablePointer</code> to an opaque C pointer.</p>
<p>The result is <code>nil</code> if <code>from</code> is <code>nil</code>.</p>
<h4>Declaration</h4><code class="language-swift">public init?&lt;T>(_ from: UnsafeMutablePointer&lt;T>?)</code></div></div><div id="init-48690522e4b66d2b1596ce439b7dd9cd" class="declaration"><a class="toggle-link" href="#comment-init-48690522e4b66d2b1596ce439b7dd9cd">init init?(_:)</a> <span class="required">Required</span><div class="comment collapse in" id="comment-init-48690522e4b66d2b1596ce439b7dd9cd"><h4>Declaration</h4><code class="language-swift">public init?(_ from: UnsafeMutableRawPointer?)</code></div></div><div id="init-48690522e4b66d2b1596ce439b7dd9cd" class="declaration"><a class="toggle-link" href="#comment-init-48690522e4b66d2b1596ce439b7dd9cd">init init?(_:)</a> <span class="required">Required</span><div class="comment collapse in" id="comment-init-48690522e4b66d2b1596ce439b7dd9cd"><h4>Declaration</h4><code class="language-swift">public init?(_ from: UnsafeRawPointer?)</code></div></div><div id="init_bitPattern-efdb52ad4dc1c4102df7aab833a3af18" class="declaration"><a class="toggle-link" href="#comment-init_bitPattern-efdb52ad4dc1c4102df7aab833a3af18">init init?(bitPattern:)</a> <span class="required">Required</span><div class="comment collapse in" id="comment-init_bitPattern-efdb52ad4dc1c4102df7aab833a3af18"><p>Creates an <code>OpaquePointer</code> from a given address in memory.</p>
<h4>Declaration</h4><code class="language-swift">public init?(bitPattern: Int)</code></div></div><div id="init_bitPattern-efdb52ad4dc1c4102df7aab833a3af18" class="declaration"><a class="toggle-link" href="#comment-init_bitPattern-efdb52ad4dc1c4102df7aab833a3af18">init init?(bitPattern:)</a> <span class="required">Required</span><div class="comment collapse in" id="comment-init_bitPattern-efdb52ad4dc1c4102df7aab833a3af18"><p>Creates an <code>OpaquePointer</code> from a given address in memory.</p>
<h4>Declaration</h4><code class="language-swift">public init?(bitPattern: UInt)</code></div></div><h3>Instance Variables</h3><div id="debugDescription-15dc1a07010ea28e38b1f4d74663fe11" class="declaration"><a class="toggle-link" href="#comment-debugDescription-15dc1a07010ea28e38b1f4d74663fe11">var debugDescription</a> <span class="required">Required</span><div class="comment collapse in" id="comment-debugDescription-15dc1a07010ea28e38b1f4d74663fe11"><p>A textual representation of the pointer, suitable for debugging.</p>
<h4>Declaration</h4><code class="language-swift">var debugDescription: String</code></div></div><h3>Instance Methods</h3><div id="hash_into-6d50cb3daa41162a12fb4542a687b393" class="declaration"><a class="toggle-link" href="#comment-hash_into-6d50cb3daa41162a12fb4542a687b393">func hash(into hasher: inout Hasher)</a> <span class="required">Required</span><div class="comment collapse in" id="comment-hash_into-6d50cb3daa41162a12fb4542a687b393"><p>Hashes the essential components of this value by feeding them into the
given hasher.</p>
<ul>
<li>Parameter hasher: The hasher to use when combining the components
of this instance.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">@inlinable public func hash(into hasher: inout Hasher)</code></div></div><h3>Type Methods</h3><div id="lhs_rhs-a606646d54567350092f2c9a8c1adc2d" class="declaration"><a class="toggle-link" href="#comment-lhs_rhs-a606646d54567350092f2c9a8c1adc2d">func !=(lhs: Self, rhs: Self) -> Bool</a> <span class="required">Required</span><div class="comment collapse in" id="comment-lhs_rhs-a606646d54567350092f2c9a8c1adc2d"><h4>Declaration</h4><code class="language-swift">public static func !=(lhs: Self, rhs: Self) -> Bool</code></div></div><div id="lhs_rhs-28a45cba8101c0b1017a22535b8b2710" class="declaration"><a class="toggle-link" href="#comment-lhs_rhs-28a45cba8101c0b1017a22535b8b2710">func ==(lhs: OpaquePointer, rhs: OpaquePointer) -> Bool</a> <span class="required">Required</span><div class="comment collapse in" id="comment-lhs_rhs-28a45cba8101c0b1017a22535b8b2710"><p>Returns a Boolean value indicating whether two values are equal.</p>
<p>Equality is the inverse of inequality. For any values <code>a</code> and <code>b</code>,
<code>a == b</code> implies that <code>a != b</code> is <code>false</code>.</p>
<h4>Declaration</h4><code class="language-swift">@inlinable public static func ==(lhs: OpaquePointer, rhs: OpaquePointer) -> Bool</code></div></div>